Hello, I am currently facing a problematic with Wi...
# help
n
Hello, I am currently facing a problematic with WireMock: I have a specific request that I want to mock which should returns undefinitely a multipart/mixed Content-type. Briefly, if I receive a GET /API/notification, the service I am trying to mock is returning every 0.5s a multipart/mixed the current time (+ a notification if something happens, but let's ignore that information for the moment). I would like to simulate the same behaviour with wiremock and return every 0.5s the following message: --boundary Notification version="1.0" dateTime1970-01-01T002929+01:00/dateTime /Notification With the following header: "Content-Type": "multipart/mixed; boundary=boundary" I tried different solution like this: {{#each (range 0 1200)}}--boundary\nNotification version=\"1.0\"\ndateTime{{now format=\"yyyy-MM-dd'T'HHmmss\"}}/dateTime\n/Notification{{/each}} But the {{now}} has the same value all along because it had been computed at the beginning. Is there an other solution without having to create my own java helper? Ps: here is my full json response: "response": { "status": 200, "headers": { "Content-Type": "multipart/mixed; boundary=boundary" }, "body": "{{#each (range 0 1200)}}--boundary\nNotification version=\"1.0\"\ndateTime{{now format=\"yyyy-MM-dd'T'HHmmss\"}}/dateTime\n/Notification{{/each}}", "transformers": [ "response-template" ], "chunkedDribbleDelay": { "numberOfChunks": 1200, "totalDuration": 1200000 } } Thanks for your feedback
l
I think you are getting the same
now
value because the template will have been cached after everything has been computed. You can disable the cache by setting the
--max-template-cache-entries
startup option to 0 (or the corresponding option if you are setting up WireMock programatically).
We have also been discussing how we can make WireMock work better in this type of scenario where you might want a number of server sent events. This is something we could be working on soon
n
I tried with --max-template-cache-entries to 0 but the result is the same. I guess the interpretation of {{#each }} is done at the beginning, which will give me the same {{now}} all along after the first response.
l
Interesting. I will have a look at that because I wasn't aware that was the case